<?php

/**
 * 用户信息Action
 * @note  实现了对了用户信息的管理
 * @class  YHXXAction
 * @file  YHXXAction.php
 * @author 赤菁风铃
 * @time  2014年03月15日 14:49:19
 */


/**
 * Class YHXXAction 用户信息Action
 */
class YHXXAction extends DefaultAction
{

    #region 用户信息管理功能

    #region 管理首页
    /**
     * 默认进入的管理列表页面
     */
    public function YHXX_Index()
    {
        #region 初始化页面参数
        $pageSize = array_key_exists("PageSize", $_GET) ? $_GET["PageSize"] : 20; //分页大小
        $pageIndex = array_key_exists("PageIndex", $_GET) ? $_GET["PageIndex"] : 1; //当前页
        $orderby = ""; //默认排序方式可以留空，如需修改需要参照　"order by YHXX.YHXX_BH "格式
        $sql = ""; //如无特殊要求，不要扩展该属性

        $params = array();
        $params['MHCX'] = $_GET['MHCX'];
        $params['YHZXX_BH'] = $_GET['YHZXX_BH'];
        $params['YHXX_ZT'] = $_GET['YHXX_ZT'];
        $params['YHXX_ZH'] = $_GET['YHXX_ZH'];
        #endregion 初始化页面参数

        //处理加密后的外键
        if (!empty($params["YHZXX_BH"])) {
            $params["YHZXX_BH"] = security_decrypt($params["YHZXX_BH"]);
            if ($params["YHZXX_BH"] == null) {
                $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
                return;
            }
        }

        //保存相关参数
        $this->assign("params", $params);
        $this->assign("Model", YHXX::query($params, $pageSize, $pageIndex, $orderby, $sql));
        //显示view
        $this->display('YHXX_Index');
    }

    #endregion 管理首页

    #region 数据添加页面
    /**
     * 数据增加初始页面
     */
    public function YHXX_Insert()
    {
        $yhxx = new YHXX($_POST);
        $this->assign("Model", $yhxx);
        $this->display('YHXX_Insert');
    }

    /**
     * 数据增加处理页面
     */
    public function YHXX_Insert_Action()
    {
        $yhxx_bh_ora = security_decrypt($_POST["YHXX_BH_ORA"]);
        if ($yhxx_bh_ora == null) {
            $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
            return;
        }
        $result = ""; //数据插入的结果
        $yhxx = new YHXX($_POST);
        $yhxx_insert = new YHXX();
        $yhxx_insert->YHXX_BH = $yhxx_bh_ora;

        //如果需要限制用户插入的信息，可选择性修改下方内容
        $yhxx_insert->YHZXX_BH = $yhxx->YHZXX_BH; //用户组信息_编号
        $yhxx_insert->YHXX_XM = $yhxx->YHXX_XM; //用户信息_姓名
        $yhxx_insert->YHXX_ZH = $yhxx->YHXX_ZH; //用户信息_账号
        $yhxx_insert->YHXX_MM = strtoupper(md5($yhxx->YHXX_MM . C("AUTO_GENERATOR_SALT"))); //用户信息_密码
        $yhxx_insert->YHXX_YX = $yhxx->YHXX_YX; //用户信息_邮箱
        $yhxx_insert->YHXX_LXDH = $yhxx->YHXX_LXDH; //用户信息_联系电话
        $yhxx_insert->YHXX_ZT = $yhxx->YHXX_ZT; //用户信息_状态
        $yhxx_insert->YHXX_TP = $yhxx->YHXX_TP; //用户信息_图片
        $result .= $yhxx_insert->insert();
        $this->ajaxReturn(array("success" => empty($result), "message" => $result));
    }

    #endregion 数据添加页面

    #region 删除数据处理
    /**
     * 根据主键删除单一对象
     */
    public function YHXX_Delete()
    {
        //参数检查
        $yhxx_bh = $_GET['YHXX_BH'];
        if (!empty($yhxx_bh)) {
            $yhxx_bh = security_decrypt($yhxx_bh);
            if ($yhxx_bh == null) {
                $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
                return;
            }
        }

        //删除数据
        $yhxx = new YHXX();
        $result = $yhxx->delete($yhxx_bh);
        $this->ajaxReturn(array("success" => empty($result), "message" => $result));
    }

    #endregion 删除数据处理

    #region 数据修改页面
    /**
     * 数据修改首页面
     */
    public function YHXX_Update()
    {
        //传入参数检查
        $yhxx_bh = $_GET['YHXX_BH'];
        if (!empty($yhxx_bh)) {
            $yhxx_bh = security_decrypt($yhxx_bh);
            if ($yhxx_bh == null) {
                $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
                return;
            }
        }

        //数据验证
        $yhxx = new YHXX();
        $result = $yhxx->fetch($yhxx_bh);
        if (!empty($result)) {
            $this->ajaxReturn(array("success" => false, "message" => "您要修改的数据已被他人删除！"));
            return;
        }

        //进入数据修改页面
        $this->assign("Model", $yhxx);
        $this->display('YHXX_Update');
    }

    /**
     * 数据修改处理页面
     */
    public function YHXX_Update_Action()
    {
        //数据验证
        $yhxx_bh_ora = security_decrypt($_POST["YHXX_BH_ORA"]);
        if ($yhxx_bh_ora == null) {
            $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
            return;
        }

        $yhxx = new YHXX($_POST);

        //检查数据是否存在
        $yhxx_update = new YHXX();
        $result = $yhxx_update->fetch($yhxx_bh_ora);
        if (!empty($result)) {
            $this->ajaxReturn(array("success" => false, "message" => "您要修改的数据已被他人删除！"));
            return;
        }

        //如果需要限制用户插入的信息，可选择性修改下方内容
        $yhxx_update->YHZXX_BH = $yhxx->YHZXX_BH; //用户组信息_编号
        $yhxx_update->YHXX_XM = $yhxx->YHXX_XM; //用户信息_姓名
        $yhxx_update->YHXX_ZH = $yhxx->YHXX_ZH; //用户信息_账号
//        $yhxx_update->YHXX_MM = $yhxx->YHXX_MM; //用户信息_密码
        $yhxx_update->YHXX_YX = $yhxx->YHXX_YX; //用户信息_邮箱
        $yhxx_update->YHXX_LXDH = $yhxx->YHXX_LXDH; //用户信息_联系电话
        $yhxx_update->YHXX_ZT = $yhxx->YHXX_ZT; //用户信息_状态
        $yhxx_update->YHXX_TP = $yhxx->YHXX_TP; //用户信息_图片
        $result .= $yhxx_update->update($yhxx_bh_ora);
        $this->ajaxReturn(array("success" => empty($result), "message" => $result));
    }

    #endregion 数据修改页面

    #region 数据查询
    /**
     * 默认进入的数据查询页面
     */
    public function YHXX_Query()
    {
        #region 初始化页面参数
        $pageSize = array_key_exists("PageSize", $_POST) ? $_POST["PageSize"] : 20; //分页大小
        $pageIndex = array_key_exists("PageIndex", $_POST) ? $_POST["PageIndex"] : 1; //当前页
        $orderby = ""; //默认排序方式可以留空，如需修改需要参照　"order by YHXX.YHXX_BH "格式
        $sql = ""; //如无特殊要求，不要扩展该属性

        $params = array();
        $params['MHCX'] = $_POST['MHCX'];
        $params['YHZXX_BH'] = $_POST['YHZXX_BH'];
        $params['YHXX_ZT'] = $_POST['YHXX_ZT'];
        $params['YHXX_ZH'] = $_POST['YHXX_ZH'];
        #endregion 初始化页面参数

        //保存相关参数
        $this->assign("params", $params);
        $this->assign("Model", YHXX::query($params, $pageSize, $pageIndex, $orderby, $sql));
        //显示view
        $this->display('YHXX_Query');
    }

    #endregion 数据查询

    #endregion 用户信息管理功能

    #region 密码重置
    /**
     * 密码重置
     */
    public function YHXX_MM()
    {
        //传入参数检查
        $yhxx_bh = $_GET['YHXX_BH'];
        if (!empty($yhxx_bh)) {
            $yhxx_bh = security_decrypt($yhxx_bh);
            if ($yhxx_bh == null) {
                $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
                return;
            }
        }

        //数据验证
        $yhxx = new YHXX();
        $result = $yhxx->fetch($yhxx_bh);
        if (!empty($result)) {
            $this->ajaxReturn(array("success" => false, "message" => "用户信息不存在！"));
            return;
        }

        //如果需要限制用户插入的信息，可选择性修改下方内容
        $yhxx->YHXX_MM = strtoupper(md5('123456' . C("AUTO_GENERATOR_SALT"))); //用户信息_密码
        $result .= $yhxx->update($yhxx_bh);
        $this->ajaxReturn(array("success" => empty($result), "message" => $result));
    }

    #endregion 密码重置

    #region 第三方登录管理功能

    #region 管理首页
    /**
     * 默认进入的管理列表页面
     */
    public function DSFDL_Index()
    {

        #region 初始化页面参数
        $pageSize = array_key_exists("PageSize", $_GET) ? $_GET["PageSize"] : 20; //分页大小
        $pageIndex = array_key_exists("PageIndex", $_GET) ? $_GET["PageIndex"] : 1; //当前页
        $orderby = ""; //默认排序方式可以留空，如需修改需要参照　"order by YHXX.YHXX_BH "格式
        $sql = ""; //如无特殊要求，不要扩展该属性

        $params = array();
        $params['YHXX_BH'] = $_GET['YHXX_BH'];
        $params['DSFDL_DLLY'] = $_GET['DSFDL_DLLY'];
        $params['DSFDL_YHID'] = $_GET['DSFDL_YHID'];
        #endregion 初始化页面参数

        //处理加密后的外键
        if (!empty($params["YHXX_BH"])) {
            $params["YHXX_BH"] = security_decrypt($params["YHXX_BH"]);
            if ($params["YHXX_BH"] == null) {
                $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
                return;
            }
        }

        //保存相关参数
        $this->assign("params", $params);
        $this->assign("Model", DSFDL::query($params, $pageSize, $pageIndex, $orderby, $sql));
        //显示view
        $this->display('DSFDL_Index');
    }

    #endregion 管理首页

    #region 数据添加页面
    /**
     * 数据增加初始页面
     */
    public function DSFDL_Insert()
    {
        $dsfdl = new DSFDL($_POST);
        $this->assign("Model", $dsfdl);
        $this->display('DSFDL_Insert');
    }

    /**
     * 数据增加处理页面
     */
    public function DSFDL_Insert_Action()
    {
        $dsfdl_bh_ora = security_decrypt($_POST["DSFDL_BH_ORA"]);
        if ($dsfdl_bh_ora == null) {
            $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
            return;
        }
        $result = ""; //数据插入的结果
        $dsfdl = new DSFDL($_POST);
        $dsfdl_insert = new DSFDL();
        $dsfdl_insert->DSFDL_BH = $dsfdl_bh_ora;

        //如果需要限制用户插入的信息，可选择性修改下方内容
        $dsfdl_insert->YHXX_BH = $dsfdl->YHXX_BH; //用户信息_编号
        $dsfdl_insert->DSFDL_YHID = $dsfdl->DSFDL_YHID; //第三方登录_用户ID
        $dsfdl_insert->DSFDL_DLSJ = date('Y-m-d H:i:s');; //第三方登录_登录时间
        $dsfdl_insert->DSFDL_DLLY = $dsfdl->DSFDL_DLLY; //第三方登录_登录来源
        $result .= $dsfdl_insert->insert();
        $this->ajaxReturn(array("success" => empty($result), "message" => $result));
    }

    #endregion 数据添加页面

    #region 删除数据处理
    /**
     * 根据主键删除单一对象
     */
    public function DSFDL_Delete()
    {
        //参数检查
        $dsfdl_bh = $_GET['DSFDL_BH'];
        if (!empty($dsfdl_bh)) {
            $dsfdl_bh = security_decrypt($dsfdl_bh);
            if ($dsfdl_bh == null) {
                $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
                return;
            }
        }

        //删除数据
        $dsfdl = new DSFDL();
        $result = $dsfdl->delete($dsfdl_bh);
        $this->ajaxReturn(array("success" => empty($result), "message" => $result));
    }

    #endregion 删除数据处理

    #region 数据修改页面
    /**
     * 数据修改首页面
     */
    public function DSFDL_Update()
    {
        //传入参数检查
        $dsfdl_bh = $_GET['DSFDL_BH'];
        if (!empty($dsfdl_bh)) {
            $dsfdl_bh = security_decrypt($dsfdl_bh);
            if ($dsfdl_bh == null) {
                $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
                return;
            }
        }

        //数据验证
        $dsfdl = new DSFDL();
        $result = $dsfdl->fetch($dsfdl_bh);
        if (!empty($result)) {
            $this->ajaxReturn(array("success" => false, "message" => "您要修改的数据已被他人删除！"));
            return;
        }

        //进入数据修改页面
        $this->assign("Model", $dsfdl);
        $this->display('DSFDL_Update');
    }

    /**
     * 数据修改处理页面
     */
    public function DSFDL_Update_Action()
    {
        //数据验证
        $dsfdl_bh_ora = security_decrypt($_POST["DSFDL_BH_ORA"]);
        if ($dsfdl_bh_ora == null) {
            $this->ajaxReturn(array("success" => false, "message" => "您传入的参数非法！"));
            return;
        }

        $dsfdl = new DSFDL($_POST);

        //检查数据是否存在
        $dsfdl_update = new DSFDL();
        $result = $dsfdl_update->fetch($dsfdl_bh_ora);
        if (!empty($result)) {
            $this->ajaxReturn(array("success" => false, "message" => "您要修改的数据已被他人删除！"));
            return;
        }

        //如果需要限制用户插入的信息，可选择性修改下方内容
        $dsfdl_update->YHXX_BH = $dsfdl->YHXX_BH; //用户信息_编号
        $dsfdl_update->DSFDL_YHID = $dsfdl->DSFDL_YHID; //第三方登录_用户ID
        $dsfdl_update->DSFDL_DLSJ = $dsfdl->DSFDL_DLSJ; //第三方登录_登录时间
        $dsfdl_update->DSFDL_DLLY = $dsfdl->DSFDL_DLLY; //第三方登录_登录来源
        $result .= $dsfdl_update->update($dsfdl_bh_ora);
        $this->ajaxReturn(array("success" => empty($result), "message" => $result));
    }

    #endregion 数据修改页面

    #region 数据查询
    /**
     * 默认进入的数据查询页面
     */
    public function DSFDL_Query()
    {
        #region 初始化页面参数
        $pageSize = array_key_exists("PageSize", $_POST) ? $_POST["PageSize"] : 20; //分页大小
        $pageIndex = array_key_exists("PageIndex", $_POST) ? $_POST["PageIndex"] : 1; //当前页
        $orderby = ""; //默认排序方式可以留空，如需修改需要参照　"order by YHXX.YHXX_BH "格式
        $sql = ""; //如无特殊要求，不要扩展该属性

        $params = array();
        $params['YHXX_BH'] = $_POST['YHXX_BH'];
        $params['DSFDL_DLLY'] = $_POST['DSFDL_DLLY'];
        $params['DSFDL_YHID'] = $_POST['DSFDL_YHID'];
        #endregion 初始化页面参数

        //保存相关参数
        $this->assign("params", $params);
        $this->assign("Model", DSFDL::query($params, $pageSize, $pageIndex, $orderby, $sql));
        //显示view
        $this->display('DSFDL_Query');
    }
    #endregion 数据查询

    #endregion 第三方登录管理功能
}